<?php
return [
    'module' => [
        'name' => 'admin_permission',
        'title' => '权限管理',
        'table' => 'admin_permissions',
    ],
    
    'fields' => [
        'id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '权限ID',
            'primary' => true,
            'auto_increment' => true,
            'nullable' => false,
            'required' => true,
        ],
        'name' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '权限名称',
            'required' => true,
            'nullable' => false,
            'rules' => 'required|unique:admin_permissions',
        ],
        'slug' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '权限标识',
            'required' => true,
            'nullable' => false,
            'rules' => 'required|unique:admin_permissions',
        ],
        'http_method' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => 'HTTP方法',
            'required' => false,
            'nullable' => true,
        ],
        'http_path' => [
            'type' => 'text',
            'comment' => 'HTTP路径',
            'required' => false,
            'nullable' => true,
        ],
        'parent_id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '父级ID',
            'default' => 0,
        ],
        'order' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '排序',
            'default' => 0,
        ],
        'icon' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '图标',
            'required' => false,
            'nullable' => true,
        ],
        'created_at' => [
            'type' => 'timestamp',
            'comment' => '创建时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true
        ],
        'updated_at' => [
            'type' => 'timestamp',
            'comment' => '更新时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true,
            'extra' => 'ON UPDATE CURRENT_TIMESTAMP'
        ],
    ],
    
    'relations' => [
        'roles' => [
            'type' => 'belongsToMany',
            'model' => 'AdminRole',
            'table' => 'admin_role_permissions',
            'foreign_key' => 'permission_id',
            'other_key' => 'role_id',
        ],
    ],
    
    'queries' => [
        'name' => ['like', '%?%'],
        'slug' => ['like', '%?%'],
        'http_path' => ['like', '%?%'],
    ],
]; 